<script>

Function.prototype.mybind = function(context){
    context = context ? context : window
    let fn = this
    let args = [...arguments].slice(1)
    return function(){
        fn.call(context,...args)
    }
}

Function.prototype.youbind = function(context){
    let that = this;
    let bindArgs = Array.prototype.slice.call(arguments, 1);
    function Fn () {};
    function fBound(params) {
        let args = Array.prototype.slice.call(arguments) ;
        return that.apply(this instanceof fBound ? this : context, bindArgs.concat(args));
    }
    Fn.prototype = this.prototype;
    fBound.prototype = new Fn();
    return fBound;
}

let obj = {
    fn:function(a,b){
        console.log(this.name + a + b)
    }
}
let obj2 = {
    name : 'gailun'
}

let newfn = obj.fn.mybind(obj2,1,2)
console.log(newfn);
newfn()

let fff = obj.fn.bind(obj2)
console.log(fff);

</script>